<template>
  <div class="communitySupportingFacilitiesInfo">
    <el-collapse v-model="collapseItems">
      <el-collapse-item name="otherConvenient">
        <template #title>
          <div class="title">
            <div class="block"></div>
            <span>其他便民商业网点</span>
          </div>
        </template>
        <div
          class="content"
          v-if="
            info &&
            info.communityOtherBusinessPeopleInfos &&
            info.communityOtherBusinessPeopleInfos.length
          "
        >
          <div
            class="building-info-item"
            v-for="(item, index) in info.communityOtherBusinessPeopleInfos"
            :key="index"
          >
            <span class="position">点位名称：{{ item.name }}</span>
            <span>大类：{{ item.topType }}</span>
            <span>中类：{{ item.middleType }}</span>
          </div>
        </div>
      </el-collapse-item>

      <el-collapse-item name="postExpress">
        <template #title>
          <div class="title">
            <div class="block"></div>
            <span>邮局快递驿站</span>
          </div>
        </template>
        <div
          class="content"
          v-if="
            info &&
            info.communityPostHouseInfos &&
            info.communityPostHouseInfos.length
          "
        >
          <div
            class="building-info-item"
            v-for="(item, index) in info.communityPostHouseInfos"
            :key="index"
          >
            <span class="position">点位名称：{{ item.name }}</span>
            <span>大类：{{ item.topType }}</span>
            <span>中类：{{ item.middleType }}</span>
          </div>
        </div>
      </el-collapse-item>

      <el-collapse-item name="supermarket">
        <template #title>
          <div class="title">
            <div class="block"></div>
            <span>综合超市便利店</span>
          </div>
        </template>
        <div
          class="content"
          v-if="
            info &&
            info.communitySupermarketInfos &&
            info.communitySupermarketInfos.length
          "
        >
          <div
            class="building-info-item"
            v-for="(item, index) in info.communitySupermarketInfos"
            :key="index"
          >
            <span class="position">点位名称：{{ item.name }}</span>
            <span>大类：{{ item.topType }}</span>
            <span>中类：{{ item.middleType }}</span>
          </div>
        </div>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

defineProps({
  info: {
    type: Object,
    default: () => {},
  },
})

const collapseItems = ref(['otherConvenient', 'postExpress', 'supermarket'])
</script>

<style scoped lang="scss">
.communitySupportingFacilitiesInfo {
  padding: 15px 10px 15px 5px;
  overflow-y: auto;
  height: 100%;

  .title {
    margin-top: 5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;

    .block {
      width: 3px;
      height: 18px;
      margin-right: 6px;
      background-color: #28b1e4;
      border-radius: 2px;
    }

    span {
      font-size: 14px;
      font-weight: bold;
    }
  }

  .content {
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;

    span {
      font-size: 14px;
      line-height: 32px;
    }

    .building-info-item {
      display: flex;
      flex-direction: column;
      padding: 11px 15px;
      background-color: rgba(249, 249, 252, 1);
      border-radius: 4px;
      margin-bottom: 12px;

      color: #717689;

      .position {
        color: RGBA(39, 71, 95, 1);
      }
    }
  }
}
</style>
